1 <?
2 if
(isset($_POST['butSaveLoai'])) {
3     $name = $_POST[
'txtName'];
4     $doituong = $_POST[
'doituong'];
5     $parent=$_POST[
'parent'];
6     $option = $_POST[
'option'];
7     $thutu = $_POST[
'thutu'];
8     
if ($name=="")
9     {
10         echo
"<p align=center class='err'>B&#7841;n ch&#432;a nh&#7853;p tên</p>";
11     }
12     
else
13     {
14         
if (!empty($_POST['oldid'])) {
15             $oldid = $_POST[
'oldid'];
16             $sql =
"update option_home set name='".$name."', doituong='".$doituong."', cat_id='".$parent."',option_home='".$option."',thutu='".$thutu."' where id='".$oldid."'";
17              }
18         
else
19             {
20             $sql =
"insert into option_home (name,doituong,cat_id,option_home,thutu) values ('".$name."','".$doituong."','".$parent."','".$option."','".$thutu."')";
21             }
22         
if (mysql_query($sql,$con))
23             {
24             echo
"<p align=center class='err'>&#272;ã c&#7853;p nh&#7853;t thành công</p><br>";
25             echo
"<script>window.location='index.php?act=option&page=".$_REQUEST['page']."'</script>";
26             }
27         
else echo "<p align=center class='err'>Không th&#7875; c&#7853;p nh&#7853;t</p>";
28 }
29 }
30 ?>
31
32 <?
33     
if (isset($_GET['id'])) {
34         $oldid=$_GET[
'id'];
35         $sql =
"select * from option_home where id='".$oldid."'";
36         
if ($result = mysql_query($sql,$con)) {
37             $row=mysql_fetch_array($result);
38             $name=$row[
'name'];
39             $doituong=$row[
'doituong'];
40             $option=$row[
'option_home'];
41             $parent=$row[
'cat_id'];
42         }
43     }
44 ?>
45
46 <form method=
"post" name="FormLoaiSP" action="index.php">
47 <input type=hidden name=
"act" value="option_m">
48 <input type=hidden name=
"oldid" value="<? echo $oldid; ?>">
49 <input type=hidden name=
"page" value="<? echo $_REQUEST['page']; ?>">
50
51 <table border=
"1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
52   <tr>
53     <td width=
"45%" align="center" class="title" height="20">Thêm m&#7899;i / C&#7853;p nh&#7853;t : Option</td>
54   </tr>
55   <tr>
56     <td width=
"45%">
57     <table border=
"0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
58       <tr>
59         <td width=
"15%" class="smallfont">
60         <p align=
"right">Tên Option</td>
61         <td width=
"1%" class="smallfont">
62         <font color=
"#FF0000">*</font></td>
63         <td width=
"83%" class="smallfont">
64         <INPUT
value="<? echo $name; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
65       </tr>
66       <tr>
67         <td width=
"15%" class="smallfont">
68         <p align=
"right">Thông số sau</td>
69         <td width=
"1%" class="smallfont">
70         <font color=
"#FF0000">*</font></td>
71         <td width=
"83%" class="smallfont">
72         <INPUT
value="<? echo $doituong; ?>" TYPE="text" NAME="doituong" CLASS=textbox size="34"></td>
73       </tr>
74 <tr>
75         <td width=
"15%" class="smallfont" align="right">
76         Thuộc tỉnh thành</td>
77         <td width=
"1%" class="smallfont" align="center">&nbsp;
78         </td>
79         <td width=
"83%" class="smallfont">
80                 <
select size="1" name="parent" >
81 <?
82         $cats=GetListCat(
17);
83         
foreach ($cats as $cat)
84         {
85             
if ($cat[0]==$parent)
86                 echo
"<option value=".$cat[0]." selected>".$cat[1]."</option>";
87             
else
88                 echo
"<option value=".$cat[0].">".$cat[1]."</option>";
89         }
90 ?>
91         </
select>
92         </td>
93       </tr>
94       <tr>
95         <td width=
"15%" class="smallfont">
96         <p align=
"right">Option</td>
97         <td width=
"1%" class="smallfont">
98         <font color=
"#FF0000">*</font></td>
99         <td width=
"83%" class="smallfont">
100         <
select name="option">
101         <?
if($row['option_home']=='0'){?>
102         <option
value="0" selected>INPUT</option>
103         <option
value="1">CHECKBOX</option>
104         <?}
else{?>
105         <option
value="1" selected>CHECKBOX</option>
106         <option
value="0">INPUT</option>
107         <?}?>
108
109         </
select>
110         </td>
111       </tr>
112       <tr>
113         <td width=
"15%" class="smallfont">
114         <p align=
"right">
115         <INPUT TYPE=
"submit" NAME="butSaveLoai" VALUE="C&#7853;p nh&#7853;t" CLASS=button>&nbsp;</td>
116         <td width=
"1%" class="smallfont">
117         &nbsp;</td>
118         <td width=
"83%" class="smallfont"><p align="left">&nbsp;<INPUT TYPE="reset" CLASS=button value="Nh&#7853;p l&#7841;i"></td>
119       </tr>
120     </table>
121     </td>
122   </tr>
123   </table>
124 </form>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.805 lượt xem

Gõ tìm kiếm nhanh...